<!DOCTYPE html>
<html>
<head>
  <title>属性管理 - {$sys_config['site_name']}</title>
  {include file="public/head" /}
</head>
<body class="hold-transition skin-blue sidebar-mini fixed">
<div class="wrapper">

  {include file="public/nav" /}
  {include file="public/menu" /}

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        属性管理
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> 控制台</a></li>
        <li class="active">属性管理</li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content container-fluid">

      <div class="row" >
        <div class="col-xs-12">
            <!-- /.box-header -->
          <div class="box">
            <div class="box-body">
              <table id="example1" class="table table-bordered table-striped">
                <thead>
                <tr>
                  <th>操作</th>
                  <th>ID</th>
                  <th>属性名称</th>
                  <th>属性值</th>
                  <th>属性扩展值</th>
                  <th>显示/隐藏</th>
                </tr>
                </thead>
                <tbody>
                
                <tr>
                  <td colspan="100"><small class="btn btn-primary btn-xs open_attr_box" menu-id="0"><i class="fa fa-plus"></i> 添加属性</small></td>
                </tr>
                {foreach name="list" item="attr"}
                <tr>
                  <td>
                    <small class="btn btn-primary btn-xs open_attr_box" attr-id="{$attr.id}"><i class="glyphicon glyphicon-edit"></i> 编辑</small>
                    <small class="btn btn-danger btn-xs del_menu" attr-id="{$attr.id}"><i class="fa fa-clock-o"></i> 删除</small></td>
                  <td>{$attr.id}</td>
                  <td>{$attr.name}</td>
                  <td>{$attr.value}</td>
                  <td>{$attr.extend}</td>
                  <td>{$attr.is_show==1?'显示':'隐藏'}</td>
                </tr>
                {/foreach}
                </tbody>
              </table>
              <div class="pull-right">{$page}</div>
            </div>

            <!-- /.box-body -->
          </div>
          <!-- /.box -->
        </div>
      </div>
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->

  {include file="public/foot" /}
</div>
<!-- ./wrapper -->
{include file="public/js" /}
<script type="text/javascript">
//根据需要填写需要的模块
layui.use('layer', function(){
  //弹出添加修改
    $('.open_attr_box').click(function() {
       var id = $(this).attr('attr-id');
        layer.open({
            type:2,
            title:'属性表单',
            btn: ['确认提交', '取消'],
            area: ['600px', '500px'],
            content: "{:url('Attr/add_attr')}?id="+id,
            yes: function (index, layero) {
                var iframeWin          = window[layero.find('iframe')[0]['name']];
                var menu_data = iframeWin.confirm();
                $.post("{:url('Attr/save_data')}", menu_data,function(res){
                    if (res.status==1){
                        layer.msg(res.msg,function(index, layero){
                                time:2000

                            });
                            location.reload();
                            return false;
                    }else{
                        layer.msg(res.msg,{time:1000});
                        return false;
                    }
                }, "json");
            }
        });
    });

    //删菜单
  $('.del_menu').click(function () {
    var id = $(this).attr('attr-id');
    layer.confirm('确定删除此属性吗',{
      btn: ['确定','取消'] //按钮
      }, function(){
        $.post("{:url('Attr/delAttr')}", {id:id},function(res){
              if (res.status==1){
                layer.msg(res.msg,function(index, layero){
                  location.reload();
                });
                
                return false;
              }else{
                layer.msg(res.msg,{time:100});
                return false;
              }
        }, "json");

      });
                
  });
});
</script>
</body>
</html>